import java.io.*;
import java.util.*;

class CrossProduct {
    
    public static void main(String[] args) {
	ArrayList<String> l1 = getList(args[0]);
	ArrayList<String> l2 = getList(args[1]);
	ArrayList<String> output = new ArrayList<String>();
	for (String line1 : l1) {
	    for (String line2 : l2) {
		output.add(line1 + " " + line2);
	    }
	}
	
	writeFile(args[2], output);
    }

    private static void writeFile(String fileName, ArrayList<String> list) {
	try {
	    BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));

	    for(String line : list) {
		writer.write(line);
		writer.newLine();
	    }

	    writer.close();
	}
	catch(Exception e) {}
    }

    private static ArrayList<String> getList(String fileName) {
	ArrayList<String> list = new ArrayList<String>(); 
	try {
	    BufferedReader reader = new BufferedReader(new FileReader(fileName));

	    String line;
	    while((line = reader.readLine()) != null) {
		line = line.trim().replaceAll("\\s+","");
		if (!line.equals("")) {
		    list.add(line);
		}
	    }

	    return list;
	}
	catch(Exception e) {}
	
	return null;
    }
}
